import cacheHandler from '@/utils/cacheHandler'

// 定义导航栏 与 tabbar 主题色
const themes = {
  'default-theme': {
    navBar: {
      backgroundColor: '#067FFA',
      frontColor: '#ffffff'
    },
    tabBar: {
      backgroundColor: '#F9F9F9',
      color: '#949494',
      selectedColor: '#067FFA',
      borderStyle: 'black'
    }
  },
  'light-theme': {
    navBar: {
      backgroundColor: '#FFFFFF',
      frontColor: '#000000'
    },
    tabBar: {
      backgroundColor: '#FFFFFF',
      color: '#000000',
      selectedColor: '#067FFA',
      borderStyle: 'white'
    }
  },
  'dark-theme': {
    navBar: {
      backgroundColor: '#000000',
      frontColor: '#ffffff'
    },
    tabBar: {
      backgroundColor: '#000000',
      color: '#FFFFFF',
      selectedColor: '#067FFA',
      borderStyle: 'black'
    }
  },
  'lament-theme': {
    navBar: {
      backgroundColor: '#FFFFFF',
      frontColor: '#000000'
    },
    tabBar: {
      backgroundColor: '#FFFFFF',
      color: '#000000',
      selectedColor: '#067FFA',
      borderStyle: 'white'
    }
  }
}

function setTheme(theme) {
  // 设置缓存
  cacheHandler.setTheme(theme)
  // 设置导航条
  uni.setNavigationBarColor(themes[theme].navBar)
  // 设置tabbar
  uni.setTabBarStyle(themes[theme].tabBar)
}

export default {
  themes,
  setTheme
}
